//
//  MainViewController.m
//  CloseLightGame
//
//  Created by dllo on 15/4/22.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "MainViewController.h"
#import "MyView.h"

@interface MainViewController ()

@end

@implementation MainViewController
- (void)dealloc
{
    [super dealloc];
}
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
    
    }
    return self;
}

- (void)changeColor:(id)sender
{
    UIButton *button = (UIButton *)sender;
    NSInteger tag = button.tag;
    for (int i = 0; i < 25; i ++) {
        if (tag == 7 || tag == 8 || tag == 9 ) {
            [(UIButton *)[self.view viewWithTag:tag] setBackgroundColor:[UIColor orangeColor]];
            [(UIButton *)[self.view viewWithTag:tag + 1] setBackgroundColor:[UIColor orangeColor]];
            [(UIButton *)[self.view viewWithTag:tag - 1] setBackgroundColor:[UIColor orangeColor]];
            [(UIButton *)[self.view viewWithTag:tag - 5] setBackgroundColor:[UIColor orangeColor]];
            [(UIButton *)[self.view viewWithTag:tag + 5] setBackgroundColor:[UIColor orangeColor]];
        }
    }
}

- (void)loadView
{
    [super loadView];
    MyView *view = [[MyView alloc] initWithFrame:self.view.frame];
    view.target = self;
    view.action = @selector(changeColor:);
    [self.view addSubview:view];
    [view release];
    NSLog(@"123");
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
